﻿using Magic.Web.Entry;
using Microsoft.AspNetCore.Mvc;

namespace Magic.Web;
/// <summary>
/// 在线用户控制器
/// </summary>
public class SysUserOnlineController : BaseController
{
    private readonly SugarRepository<SysUserOnline> _onlineUserRep;
    private readonly IOnlineUserService _onlineUserService;

    public SysUserOnlineController(SugarRepository<SysUserOnline> onlineUserRep,
                                IOnlineUserService onlineUserService)
    {
        _onlineUserRep = onlineUserRep;
        _onlineUserService = onlineUserService;
    }
    /// <summary>
    /// 分页返回在线用户
    /// </summary>
    [HttpPost("getIndex")]
    public async Task<dynamic> GetIndex([FromQuery] BasePageInput pagination, [FromBody] OnlineUserQueryInput input)
    {
        return await _onlineUserService.GetOnlineUsersPage(pagination, input);
    }


    /// <summary>
    /// 强制下线
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost("forceExist")]
    public async Task ForceExist(OnlineUserInput input)
    {
        await _onlineUserService.ForceExist(input);
    }
}
